import { random } from 'sard-uniapp'

export function getPrizes() {
	return [
    { id: 1, name: '请我吃好吃的', icon: 'a-aixihuanliukoushuisebiaoqingxiaolian' },
    { id: 2, name: '给我买零食', icon: 'a-baochitaiduobiaoqingxiaolian' },
    { id: 3, name: '朋友圈道歉', icon: 'a-bizuigangabiaoqingxiaolian' },
    { id: 4, name: '任选一个', icon: 'a-aiqingxihuansebiaoqingxiaolian' },
    { id: 5, name: '转账111', icon: 'a-aimujingpeijingyangwasejingyabiaoqingxiaolian' },
    { id: 6, name: '买新衣服', icon: 'a-gangaliuhanbiaoqingxiaolian' },
    { id: 7, name: '一支口红', icon: 'a-bucuohaochiweidaobiaoqingxiaolian' },
    { id: 8, name: '撒娇十连', icon: 'a-eabukenengbiaoqingxiaolian' },
    { id: 9, name: '全部来一次', icon: 'a-jingyajingqiwasetianlabiaoqingxiaolian' },
    { id: 10, name: '打屁股52下', icon: 'a-gaoxinghaoxinqingbiaoqingxihuanbiaoqingxiaolian' },
    { id: 11, name: '写检讨', icon: 'a-keaiyouqudeganxingqubiaoqingxiaolian' },
    { id: 12, name: '再转一次', icon: 'a-keshuishuijuebiaoqingxiaolian' },
    { id: 13, name: '两天不许玩游戏', icon: 'a-nulifendoujiayoubiaoqingxiaolian' },
    { id: 14, name: '请我喝奶茶', icon: 'a-dakubeishangshangxinbiaoqingxiaolian' },
	]
}

export interface Prize {
	id : number
	name : string
	icon : string
}

export const getPrizesApi = async (count : number) => {
	return new Promise<Prize[]>((resolve) =>
		setTimeout(resolve, 150, getPrizes().slice(0, count)),
	)
}

export const getPrizeApi = async (count : number) => {
	return new Promise<Prize>((resolve) =>
		setTimeout(resolve, 150, getPrizes()[random(0, count - 1)]),
	)
}

export const getMultiPrizeApi = async (columns : number[]) => {
	return new Promise<Prize[]>((resolve) =>
		setTimeout(
			resolve,
			150,
			columns.map((column) => getPrizes()[random(0, column - 1)]),
		),
	)
}